const mix = (...mixins) => {
    class Mix {}
    // 以编程方式给Mix类添加

    // mixins的所有方法和访问器
    for (let mixin of mixins) {
        copyProperties(Mix, mixin);
        copyProperties(Mix.prototype, mixin.prototype);
    }
    return Mix;
};

const copyProperties = (target, source) => {
    for (var key in  Object.getOwnPropertyNames(source)) {
        //for (let key of Reflect.ownKeys(source)) {
       if ( Object.getOwnPropertyNames(source)[key] !== "constructor" &&
        Object.getOwnPropertyNames(source)[key] !== "length" && 
        Object.getOwnPropertyNames(source)[key] !== "prototype" &&
         Object.getOwnPropertyNames(source)[key] !== "name") {
           let desc = Object.getOwnPropertyDescriptor(source, Object.getOwnPropertyNames(source)[key]);
           Object.defineProperty(target, Object.getOwnPropertyNames(source)[key], desc);
       }
   }
};

export default mix